package com.wxw.demo.controller;

import com.wxw.demo.bean.Comment;
import com.wxw.demo.service.ApiCommentService;
import com.wxw.demo.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author wxw
 * @data 2020/9/7 16 :53
 * @description
 */
@RestController
@RequestMapping("/api")
public class ApiCommentController {
    @Autowired
    private ApiCommentService apicommentService;
    @GetMapping("/get/{id}")
    private Comment  findById(@PathVariable("id") int comment_id){
        Comment comment = apicommentService.finById(comment_id);
        return comment;
    }
    @GetMapping("/update/{id}/{author}")
    private Comment  updateComment(@PathVariable("id") int comment_id,@PathVariable("author") String author){
        Comment comment = apicommentService.finById(comment_id);
        comment.setAuthor(author);
        Comment updateComment = apicommentService.updateComment(comment);
        return updateComment;
    }
    @GetMapping("/delete/{id}")
    private void   deleteComment(@PathVariable("id") int comment_id){
        apicommentService.deleteComment(comment_id) ;
    }

}
